package com.kingsoft.dc.khaos

import com.kingsoft.dc.khaos.metadata.Dependency

/**
  * Created by chengguangqing on 2019/6/2.
  */
class DataSetChannel {
  private var _dataSetChannel = Map[Dependency,Any]()

  def emit[T](dataSet: T): Unit = {
    emit(Dependency(null, null, "default"), dataSet)
  }

  def emit[T](dependency: Dependency, dataSet: T): Unit = {

    _dataSetChannel +=(dependency -> dataSet)
  }

  def getDataSet[T](dependency: Dependency): T ={
    _dataSetChannel.get(dependency).map(_.asInstanceOf[T]).get
  }

  def remove(dep : Dependency):Unit ={
    _dataSetChannel = _dataSetChannel - dep
  }

  def list(): Seq[Dependency] = _dataSetChannel.keys.toSeq
}
